package com.lanchetech.user.controller;

import com.lanchetech.bean.request.PageReq;
import com.lanchetech.bean.response.BasePageResp;
import com.lanchetech.bean.response.BaseResp;
import com.lanchetech.bean.response.ResultData;
import com.lanchetech.bean.vo.VideoVO;
import com.lanchetech.entity.User;
import com.lanchetech.entity.Video;
import com.lanchetech.user.service.VideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

@Api(value = "视频接口", tags = "视频接口")
@RequestMapping("/api/video")
@RestController
public class VideoController {

    @Autowired
    VideoService videoService;

    @ApiOperation("获取视频详细信息")
    @GetMapping("/getVideoDetail")
    public ResultData<VideoVO> getVideoDetail(@AuthenticationPrincipal User user, @RequestParam("id") Long id) {
        return videoService.getVideoDetail(user, id);
    }

//    @ApiOperation("创建和编辑视频")
//    @PostMapping("/editVideo")
//    public BaseResp editVideo(@RequestBody Video video) {
//        return videoService.editVideo(video);
//    }

    @ApiOperation("获取所有视频列表")
    @PostMapping("/getVideoPage")
    public ResultData<BasePageResp<VideoVO>> getVideoPage(@AuthenticationPrincipal User user, @RequestBody PageReq req) {
        return videoService.getVideoPage(user, req);
    }

//    @ApiOperation("删除视频")
//    @GetMapping("/deleteVideo")
//    public BaseResp deleteVideo(@RequestParam("id") Long id) {
//        return videoService.deleteVideo(id);
//    }

    @ApiOperation("视频点赞")
    @GetMapping("/toggleVideoGoods")
    public BaseResp toggleVideoGoods(@RequestParam("id") Long id) {
        return videoService.toggleVideoGoods(id);
    }

}
